import { defineStore } from "pinia";
import { ref } from "vue";

export const usePermissStore = defineStore(
  "permiss",
  () => {
    const defaultList = {
      admin: ["10", "11", "12", "13", "15", "16", "17", "21", "22"],
      user: ["10", "11", "12", "13", "14", "15", "16", "17"],
    };
    const username = localStorage.getItem("username");
    const key = ref<string[]>([]);
    if (username) {
      key.value = username == "admin" ? defaultList.admin : defaultList.user;
    }

    const handleSet = (val: string[]) => {
      key.value = val;
    };
    return {
      defaultList,
      key,
      handleSet,
    };
  },
  {
    persist: true,
  }
);
